﻿using BW.WMS.WareHouseManage;
using BW.WMS.WareHouseStatistics;
using BW.WMS.WareHouseStatistics.Statistics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus.Local;

namespace BW.WMS.Controllers
{
    [Route("/api/app/statistics")]
    [ApiController]
    public class StatisticsController : ControllerBase
    {
        private readonly IStatisticsAppService _statisticsAppService;

        public StatisticsController(IStatisticsAppService statisticsAppService)
        {
            _statisticsAppService = statisticsAppService;
        }

        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet("export-data")]
        public async Task<IActionResult> ExportDataAsync([FromQuery] ExportFilterDto filter)
        {
            var bytes = await _statisticsAppService.ExportDataAsync(filter);
            var fileName = $"库存统计_{DateTime.Now:yyyyMMddHHmmss}.xlsx";

            return File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
        }



    }
}
